"""TheLastProject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.static import serve
from TheLastProject.settings import MEDIA_ROOT
from rest_framework.documentation import include_docs_urls
from goods.views import GoodViewSet,GoodCategoryViewSet,BannerViewSet,IndexGoodsViewSet
from rest_framework_jwt.views import obtain_jwt_token
from users.views import SmsCodeViewSet,UserViewset
from rest_framework.routers import DefaultRouter
from user_operation.views import *
from trade.views import *

router = DefaultRouter()
router.register("goods", GoodViewSet, base_name="goods")
router.register("categorys", GoodCategoryViewSet, base_name="categorys")
router.register("banners",BannerViewSet, base_name="banners")
router.register("indexgoods",IndexGoodsViewSet, base_name="indexgoods")
router.register("codes",SmsCodeViewSet, base_name="codes")
router.register("users", UserViewset, base_name="users")
router.register("userfavs", UserFavViewSet, base_name="userfavs")
router.register("messages",UserLeavingMessageViewSet, base_name="messages")
router.register("address", UserAddressViewSet, base_name="address")
router.register("shopcarts",ShoppingCartView, base_name="shopcarts")
router.register("orders",OrderView, base_name="orders")
urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^media/(?P<path>.*)/$', serve, {'document_root':MEDIA_ROOT}),
    path("", include(router.urls)),
    path("docs/",include_docs_urls(title="天天生鲜")),
    re_path('^login',obtain_jwt_token),
]
